package com.example.goodrubish.Garbage;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.example.goodrubish.R;

import java.util.ArrayList;
import java.util.List;

public class OnboardAdapter extends FragmentStatePagerAdapter {

    private final int NUM_PAGES = 4; // 假设有三张轮播图
    private List<Integer> imageResources;

    public OnboardAdapter(@NonNull FragmentManager fm, int behavior) {
        super(fm, behavior);
        imageResources = new ArrayList<>();
        imageResources.add(R.drawable.xinwen); // 替换为实际图片资源ID
        imageResources.add(R.drawable.laji); // 替换为实际图片资源ID
        imageResources.add(R.drawable.zhishi); // 替换为实际图片资源ID
        imageResources.add(R.drawable.ditan); // 替换为实际图片资源ID
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        int imageResourceId = imageResources.get(position);
        return OnboardFragment.newInstance(imageResourceId); // 注意这里传递的是int类型的资源ID
    }

    @Override
    public int getCount() {
        return imageResources.size();
    }
}